<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>金融数据上报管理</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div tabid="tabA" title="金融数据上报管理" lselected="true">
            <div class="searchArea">
                <form id="searchBar">
                    <div class="fieldset1 clearFix">
                        <div class="fieldBox">
                            <div class="label">支付表号</div>
                            <div class="field">
                                <input name="busSourceId" id="busSourceId" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox">
                            <div class="label">机构名称</div>
                            <div class="field">
                                <input name="fundNm" id="fundNm" type="text" class="ui-textbox" value="">
                            </div>
                        </div>
                        <div class="fieldBox">
                            <div class="label">-所属事业部-</div>
                            <div class="field">
                                <select name="prjOrg" id="prjOrg">
                                    <option value="" seleted>-请选择-</option>
                                    <c:forEach items="${orgListList }" var="org">
                                        <option value="${org.key }">${org.value }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>

                        <div class="fieldBox col_33" >
                            <div class="label">机构放款时间</div>
                            <div class="field">
                                <input name="startTm" id="startTm" type="text" class="ui-datepicker" value="">
                                <span>-</span>
                                <input name="endTm" id="endTm" type="text" class="ui-datepicker" value="">
                            </div>
                        </div>

                        <div class="fieldBox">
                            <div class="label">项目类型</div>
                            <div class="field">
                                <select name="prjType"  id="prjType" >
                                    <option value="" selected="selected">-请选择-</option>
                                    <c:forEach items="${projectTypeList}" var="opt">
                                        <option value="${opt.key}">${opt.value}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>

                        <div class="fieldBox col_33" >
                            <div class="label">逾期天数</div>
                            <div class="field">
                                <input ligerui="width: 82" name="overdueDayMin" id="overdueDayMin" type="text" class="ui-textbox" value="">
                                <span>-</span>
                                <input ligerui="width: 82" name="overdueDayMax" id="overdueDayMax" type="text" class="ui-textbox" value="">
                            </div>
                        </div>

                        <div class="clearFix"></div>
                        <div class="btnsBox">
                            <span id="searchBtn"  class="sq-button sq-button-round">查询</span>
                            <span id="clearBtn"  class="sq-button sq-button-round">清空</span>
                            <span id="submitRiskBtn"  class="sq-button sq-button-round" onclick="submitRisk(2)">风险担保上报</span>
                            <span id="submitBtn"  class="sq-button sq-button-round" onclick="submitRisk(1)">非风险担保上报</span>
                            <span id="getDataBtn"  class="sq-button sq-button-round" onclick="getData()">刷新数据</span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="sqPanel_body">
                <div id="ligergrid1" class="sq-grid"></div>
            </div>
        </div>
        <%--<div tabid="tabB" title="待上报管理" id="tabBId">
            <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
        </div>--%>
        <div tabid="tabC" title="入库异常数据" id="tabCId">
            <iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
        </div>
    </div>
</div>
</body>

<script type="text/javascript">
    var grid = null;
    var pageInApp = {}; // to 下一级子窗口 接口
    var pageInTab = null;
    var submitNum = 0;
    var getDataNum = 0;
    $(function () {
        initTab();
        var _url = '<%=path%>/fgi/fgibusinfo/initList.do?isSub=0';
        $("#ligergrid1").ligerGrid({
            url: _url,
            //parms:{},
            method: 'get',
            columns: [
                { display: '支付表号', name: 'busSourceId', minWidth: 180 ,enabledSort:true},
                { display: '客户', name: 'cstNm', minWidth: 100,align:'center', enabledSort:true},
                { display: '所属事业部', name: 'prjOrgNm', width: 100 , enabledSort:true},
                { display: '项目类型', name: 'prjTypeNm', width: 150, enabledSort:true},
                { display: '是否资管业务', name: 'isCap', minWidth: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        if (rowdata.isCap == 1) {
                            return "是";
                        } else if (rowdata.isCap == 0) {
                            return "否";
                        }
                    }
                },
                { display: '机构名称', name: 'fundNm', minWidth: 150 , enabledSort:true},
                { display: '机构实际付款时间', name: 'createTime', minWidth: 150 , enabledSort:true},
                /*{ display: '系统支付表状态', name: 'guaranteeStatus', minWidth: 150 , enabledSort:true},*/
                { display: '担保类型', name: 'guaranteeType', minWidth: 100 , enabledSort:true},
                { display: '合同担保金额(元)', name: 'guaranteeMoney', minWidth: 100 , enabledSort:true},
                { display: '担保余额(元)', name: 'guaranteeSurplusMoney', minWidth: 100 , enabledSort:true},
                { display: '逾期天数(天)', name: 'overdueDay', minWidth: 100,align:'center', enabledSort:true},
                { display: '分担比例', name: 'shareProportion', minWidth: 100 , enabledSort:true},
                { display: '融资用途', name: 'financePurpose', minWidth: 100 , enabledSort:true},
                { display: '担保开始日期', name: 'startTime', minWidth: 150 , enabledSort:true},
                { display: '担保结束日期', name: 'endTime', minWidth: 150 , enabledSort:true},
                { display: '是否农民', name: 'isAgriculture', minWidth: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        if (rowdata.isAgriculture == 1) {
                            return "是";
                        } else if (rowdata.isAgriculture == 0) {
                            return "否";
                        }
                    }
                },
                { display: '创建时间', name: 'createTime', minWidth: 150 , enabledSort:true},
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            fixedCellHeight: false,
            rownumbers: true,
//			onAfterShowData: getFlowIds,
        });
        grid = liger.get("ligergrid1");
        grid.setHeight(100);
        $("#searchBar").ligerForm();
        $('#reasonFromSet').ligerForm({
            validate: true
        });

        $("#searchBtn").click(function (event) {
            submitNum = 0;
            getDataNum = 0;
            var form = new liger.get("searchBar");
            var data = form.getData();
            console.log(JSON.stringify(data));
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            ;
            grid.reload();
        });
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "busSourceId": " ",
                "fundNm": " ",
                "prjOrg": " ",
                "startTm": " ",
                "endTm": " ",
                "prjType": " ",
                "overdueDayMin": " ",
                "overdueDayMax": " ",
            });
        });
    });

    var loadedTabs = [];

    //初始化Tab页签
    function initTab() {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function (tabid) {
                loadedTabs.push(tabid)
                switch (tabid) {
                    case "tabB":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/fgi/fgibusinfo/toMakeSureSubmitPage.do");
                        break;
                    case "tabC":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/fgi/fgiPostRes/toListPage.do");
                        break;
                }
            }
        });
        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });

    };

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    function submitRisk(value){
        if(submitNum > 0){
            parent.ligerDialogSuc("点击太快，处理中,请稍后或刷新页面...");
            return;
        }
        var wait_dialog=parent.$.ligerDialog.SQalert({content: '处理中,请稍后...' ,SQ_type: "waitting" });
        submitNum = 1;
        var form = new liger.get("searchBar");
        var _data = form.getData();
        var _url = '<%=path%>/fgi/fgibusinfo/submit.do?isSub=0&isRisk=' + value;
        $.ajax({
            type:'get',
            dataType:'json',
            async:false,
            url:_url,
            data:_data,
            success:function(msg){
                wait_dialog.close();
                if(msg.success == 1){//成功
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                    grid.reload();
                }else{
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            },
            error:function(msg){
                $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
            }
        });
    }

    function getData(){
        if(getDataNum > 0){
            parent.ligerDialogSuc("点击太快，处理中,请稍后或刷新页面...");
            return;
        }
        var wait_dialog=parent.$.ligerDialog.SQalert({content: '处理中,请稍后...' ,SQ_type: "waitting" });
        getDataNum = 1;
        var form = new liger.get("searchBar");
        var _data = form.getData();
        var _url = '<%=path%>/fgi/fgibusinfo/getData.do';
        $.ajax({
            type:'get',
            dataType:'json',
            async:false,
            url:_url,
            data:_data,
            success:function(msg){
                wait_dialog.close();
                if(msg.success == 1){//成功
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                    grid.reload();
                }else{
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            },
            error:function(msg){
                $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
            }
        });
    }

</script>
</html>